package jnpf.controller;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import jnpf.base.service.BillRuleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jnpf.base.ActionResult;
import jnpf.base.vo.PageListVO;
import jnpf.base.vo.PaginationVO;
import jnpf.base.UserInfo;
import jnpf.base.vo.DownloadVO;
import jnpf.config.ConfigValueUtil;
import jnpf.exception.DataException;
import org.springframework.transaction.annotation.Transactional;
import jnpf.base.entity.ProvinceEntity;
import jnpf.model.whu_typemessage.*;
import jnpf.model.whu_typemessage.Whu_typemessagePagination;
import jnpf.model.whu_typemessage.Whu_typemessageCrForm;
import jnpf.model.whu_typemessage.Whu_typemessageInfoVO;
import jnpf.model.whu_typemessage.Whu_typemessageListVO;
import jnpf.model.whu_typemessage.Whu_typemessageUpForm;
import jnpf.entity.*;
import jnpf.base.service.ProvinceService;
import jnpf.util.*;
import jnpf.base.util.*;
import jnpf.base.vo.ListVO;
import jnpf.util.context.SpringContext;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import jnpf.entity.Whu_typemessageEntity;
import jnpf.service.Whu_typemessageService;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.multipart.MultipartFile;
import javax.validation.Valid;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.*;


/**
 *
 * whu_typemessage
 * @版本： V3.2.0
 * @版权： 引迈信息技术有限公司（https://www.jnpfsoft.com）
 * @作者： JNPF开发平台组
 * @日期： 2025-06-10
 */
@Slf4j
@RestController
@Api(tags = "whu_typemessage" , value = "example")
@RequestMapping("/api/example/Whu_typemessage")
public class Whu_typemessageController {


    @Autowired
    private GeneraterSwapUtil generaterSwapUtil;
    @Autowired
    private UserProvider userProvider;

    @Autowired
    private Whu_typemessageService whu_typemessageService;



    /**
     * 列表
     *
     * @param whu_typemessagePagination
     * @return
     */
	@PostMapping("/getList")
    public ActionResult list(@RequestBody Whu_typemessagePagination whu_typemessagePagination)throws IOException{
        List<Whu_typemessageEntity> list= whu_typemessageService.getList(whu_typemessagePagination);
        //处理id字段转名称，若无需转或者为空可删除
    for(Whu_typemessageEntity entity:list){
    }
	List<Whu_typemessageListVO> listVO=JsonUtil.getJsonToList(list,Whu_typemessageListVO.class);
    for(Whu_typemessageListVO whu_typemessageVO:listVO){
            }



        PageListVO vo=new PageListVO();
        vo.setList(listVO);
        PaginationVO page=JsonUtil.getJsonToBean(whu_typemessagePagination,PaginationVO.class);
        vo.setPagination(page);
        return ActionResult.success(vo);
    }


    /**
     * 创建
     *
     * @param whu_typemessageCrForm
     * @return
     */
    @PostMapping
    @Transactional
    public ActionResult create(@RequestBody @Valid Whu_typemessageCrForm whu_typemessageCrForm) throws DataException {
        String mainId =RandomUtil.uuId();
        UserInfo userInfo=userProvider.get();
        Whu_typemessageEntity entity = JsonUtil.getJsonToBean(whu_typemessageCrForm, Whu_typemessageEntity.class);
				entity.setId(mainId);
                whu_typemessageService.save(entity);


        return ActionResult.success("创建成功");
}




    /**
    * 信息
    *
    * @param id
    * @return
    */
    @GetMapping("/{id}")
    public ActionResult<Whu_typemessageInfoVO> info(@PathVariable("id") String id){
        Whu_typemessageEntity entity= whu_typemessageService.getInfo(id);
        Whu_typemessageInfoVO vo=JsonUtil.getJsonToBean(entity, Whu_typemessageInfoVO.class);

        return ActionResult.success(vo);
    }





   /**
    * 更新
    *
    * @param id
    * @return
    */
    @PutMapping("/{id}")
    @Transactional
    public ActionResult update(@PathVariable("id") String id,@RequestBody @Valid Whu_typemessageUpForm whu_typemessageUpForm) throws DataException {
        UserInfo userInfo=userProvider.get();
        Whu_typemessageEntity entity= whu_typemessageService.getInfo(id);
        if(entity!=null){
            Whu_typemessageEntity subentity=JsonUtil.getJsonToBean(whu_typemessageUpForm, Whu_typemessageEntity.class);
            whu_typemessageService.update(id, subentity);
        return ActionResult.success("更新成功");
        }else{
            return ActionResult.fail("更新失败，数据不存在");
        }
    }

   /**
    * 删除
    *
    * @param id
    * @return
    */
    @DeleteMapping("/{id}")
    @Transactional
    public ActionResult delete(@PathVariable("id") String id){
        Whu_typemessageEntity entity= whu_typemessageService.getInfo(id);
        if(entity!=null){
            whu_typemessageService.delete(entity);

        }
        return ActionResult.success("删除成功");
    }


}
